'''
Created on Jun 6, 2012

@author: vnikodijevic
'''

import xlwt
import functions #custom module - path is appended in main

class execute():
    '''
        Class with methods to produce various reports.
    '''


    def __init__(self):
        '''
        Constructor
        '''

    def createExcelReport(self,tpl,path):
        ''' 
            Function to crete report based on provided data.
            
            tpl(tuple) - parameter is tuple of lists:
                Form of tuple's member list must be:
                    1-st member:     Hostname(string)
                    2-nd member:     Subject(string)
                    3-th member:     Valid To(date)
                    4-th member:     Is Expired(boolen)
            
            path(string) - absolute path to reports dir where report will create
            
        '''
        
        wbk = xlwt.Workbook()
        sheet = wbk.add_sheet('CertsDetails')

        sheet.write(0,0,"Hostname")
        sheet.write(0,1,"Subject")
        sheet.write(0,2,"Valid To")
        sheet.write(0,3,"Is Expired")
        
        i=1
        
        for lst in tpl:
            host=lst[0]
            subject=lst[1]
            valid_to=lst[2]
            is_expired=lst[3]
            sheet.write(i,0,host)
            sheet.write(i,1,subject)
            sheet.write(i,2,valid_to)
            sheet.write(i,3,is_expired)
            i=i+1
        
        
        wbk.save(path+'report_'+ functions.Custom().cDate() +'.xls')
                